home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_13_11 / phillip2 / mainas.c < prev    next >
C/C++ Source or Header  |  1993-06-25  |  4KB  |  137 lines

  1.  
  2.  
  3.    /***********************************************
  4.    *
  5.    *   file d:\cips\mainas.c
  6.    *
  7.    *   Functions: This file contains
  8.    *      main
  9.    *
  10.    *   Purpose:
  11.    *      This file contains the main calling
  12.    *      routine in an image addition and subtraction
  13.    *      program.
  14.    *
  15.    *   External Calls:
  16.    *      gin.c - get_image_name
  17.    *      numcvrt.c - get_integer
  18.    *                  int_convert
  19.    *      tiff.c - read_tiff_header
  20.    *      addsub.c - add_image
  21.    *                 subtract_image
  22.    *
  23.    *   Modifications:
  24.    *      1 April 1992 - created
  25.    *
  26.    *************************************************/
  27.  
  28. #include "cips.h"
  29.  
  30.  
  31.  
  32. short the_image[ROWS][COLS];
  33. short out_image[ROWS][COLS];
  34.  
  35. main(argc, argv)
  36.    int argc;
  37.    char *argv[];
  38. {
  39.  
  40.    char     name[80], name2[80], name3[80];
  41.    int      count, i, j, length, lw,
  42.             type, width,
  43.             il1, ie1, ll1, le1,
  44.             il2, ie2, ll2, le2,
  45.             il3, ie3, ll3, le3;
  46.    struct   tiff_header_struct image_header;
  47.    my_clear_text_screen();
  48.  
  49.        /******************************************
  50.        *
  51.        *  Interpret the command line parameters.
  52.        *
  53.        *******************************************/
  54.  
  55.    if(argc < 5 || argc > 5){
  56.     printf(
  57.      "\n"
  58.      "\n usage: mainas in1-file in2-file "
  59.      "out_file add-subtract"
  60.      "\n"
  61.      "\n   recall add-subtract a=add s=subtract\n");
  62.     exit(0);
  63.    }
  64.  
  65.    strcpy(name, argv[1]);
  66.    strcpy(name2, argv[2]);
  67.    strcpy(name3, argv[3]);
  68.  
  69.    il1 = 1;
  70.    ie1 = 1;
  71.    ll1 = ROWS+1;
  72.    le1 = COLS+1;
  73.  
  74.    il2 = 1;
  75.    ie2 = 1;
  76.    ll2 = ROWS+1;
  77.    le2 = COLS+1;
  78.  
  79.    il3 = 1;
  80.    ie3 = 1;
  81.    ll3 = ROWS+1;
  82.    le3 = COLS+1;
  83.  
  84.        /******************************************
  85.        *
  86.        *  Read the input image header and setup
  87.        *  the looping counters.
  88.        *
  89.        *  If high or low pass filtering, setup
  90.        *  the filter mask array.
  91.        *
  92.        *******************************************/
  93.  
  94.    read_tiff_header(name, &image_header);
  95.  
  96.    length = (ROWS-10 + image_header.image_length)/ROWS;
  97.    width  = (COLS-10 + image_header.image_width)/COLS;
  98.    count  = 1;
  99.    lw     = length*width;
  100.    printf("\nlength=%d  width=%d", length, width);
  101.  
  102.        /********************************************
  103.        *
  104.        *   Loop over the input images and either
  105.        *   add or subtract them.
  106.        *
  107.        ********************************************/
  108.  
  109.    for(i=0; i<length; i++){
  110.       for(j=0; j<width; j++){
  111.          printf("\nrunning %d of %d", count, lw);
  112.          count++;
  113.  
  114.          if(argv[4][0] == 'a' || argv[4][0] == 'A')
  115.             add_image_array(name, name2, name3,
  116.                the_image, out_image,
  117.                il1+i*ROWS, ie1+j*COLS, 
  118.                ll1+i*ROWS, le1+j*COLS,
  119.                il2+i*ROWS, ie2+j*COLS, 
  120.                ll2+i*ROWS, le2+j*COLS,
  121.                il3+i*ROWS, ie3+j*COLS, 
  122.                ll3+i*ROWS, le3+j*COLS);
  123.  
  124.          if(argv[4][0] == 's' || argv[4][0] == 'S')
  125.             subtract_image_array(name, name2, name3,
  126.                the_image, out_image,
  127.                il1+i*ROWS, ie1+j*COLS, 
  128.                ll1+i*ROWS, le1+j*COLS,
  129.                il2+i*ROWS, ie2+j*COLS, 
  130.                ll2+i*ROWS, le2+j*COLS,
  131.                il3+i*ROWS, ie3+j*COLS, 
  132.                ll3+i*ROWS, le3+j*COLS);
  133.  
  134.       }  /* ends loop over j */
  135.    }  /* ends loop over i */
  136. }  /* ends main  */
  137.